#ifndef BALLLIST_H
#define BALLLIST_H

#include <QObject>
#include "ballfm.h"
#include "btnfm.h"
#include "listform.h"

typedef QList<SCustomBallForm*> SBalls;
typedef SBalls::iterator SBallIter;
typedef QMap<QString, SCustomBallForm*> SBallMap;

class SBallList : public QObject
{
    Q_OBJECT

private:
    SBalls Balls;
    SBallMap ballMap;

    SCustomBallForm* CurItem;
    void doWave();

//    SListForm *listForm;

    // for scroll:
//    SButtonForm *btnUp;
//    SButtonForm *btnDown;
//    int scrollDelta;
//    void doScroll();
//    int FMaxBalls;
//    SCustomBallForm* UpItem;
//    int UpItemIdx;

protected:
    void timerEvent(QTimerEvent *timer);

public:
    explicit SBallList(QWidget *parent = 0);
    ~SBallList();

//    void scrollBalls(int delta);

    SBallForm* getBallByUin(QString uin) {return dynamic_cast<SBallForm*>(ballMap.value(uin, 0L));}

//    SBallForm* add(QString uin, QString nick);
    SBallForm* add(UserInfo *user);
    void remove(QString uin);
    void clear();

    void setUserStatus(QString uin, UserStatus status);

    bool ololo;
//    int MaxBalls;

private slots:
//    void onScrollClicked(QObject *sender);
//    void onBallWheeled(QObject *sender, int wheelDelta);
    void onBallPressed(QObject *sender);
    void onBallSend(SMessage *msg);
    void onBallClosed();
    void onBallWantClose();

public slots:
    void ReceiveMessage(SMessage *msg);

signals:
    void onSend(SMessage *msg);
    void ballWantClose(QString uin);
};

#endif // BALLLIST_H
